package model;

import java.util.ArrayList;
import java.util.List;

import view.themas.Thema;

public abstract class PresenteerbareCollectie extends Presenteerbaar {

	int aantalItems = 0;

	public PresenteerbareCollectie() {
		items = new ArrayList<Presenteerbaar>();
	}

	private List<Presenteerbaar> items;

	public List<Presenteerbaar> getItems() {
		return items;
	}

	public void setItems(List<Presenteerbaar> items) {
		this.items = items;
		setChanged();
		notifyObservers();
	}

	protected int currentItem = 0;

	public void voegItemToe(Presenteerbaar item) {
		items.add(item);
		setChanged();
		notifyObservers();
	}

	@Override
	public void setThema(Thema thema) {
		super.setThema(thema);
		for (Presenteerbaar item : items) {
			item.setThema(thema);
		}
	}

	@Override
	public boolean gaNaar(int slideNummer) {
		if (slideNummer > 0 && slideNummer < items.size()+1) {
			currentItem = slideNummer - 1;
			setChanged();
			notifyObservers();
			return true;
		}
		return false;
	}

	@Override
	public boolean volgende() {
		if (currentItem < items.size() - 1) {
			currentItem++;
			setChanged();
			notifyObservers();
			return true;
		}
		return false;

	}

	@Override
	public boolean vorige() {
		if (currentItem > 0) {
			currentItem--;
			setChanged();
			notifyObservers();
			return true;
		}
		return false;
	}
}
